<template>
  <div class="chat-box">
    <div class="box-title">
      BasicFinder|<span>客服中心</span>
    </div>
    <div class="box-container">
      <div class="title">
        <img src="../../assets/images/xuan.jpg" width="40px" height="40px" class=""/>
         在线客服 |
        <div>专门为你解决各类账户、订单、支付等问题，快速响应</div>
      </div>
      <div class="chat-content">
        <div class="des">在线客服为您服务</div>
        <ul class="content">
          <li v-for="(item, index) in messageList" :key="index">
            <img src="../../assets/images/xuan.jpg"  width="40px" height="50px" :class="'img'+(item.isSelf?'right':'left')">
            <span class="dialog">{{item.message}}</span>
          </li>
        </ul>
      </div>
      <!------底部的用户输入栏-->
      <div class="box-bottom">
        <b-input-group>
          <b-form-input v-model="inputValue" @keyup.enter="chat"> </b-form-input>
          <b-input-group-append>
            <b-button variant="outline-success" @click="chat">发送</b-button>
          </b-input-group-append>
        </b-input-group>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'mychat',
  data () {
    return {
      inputValue: '',
      isself: true,
      messageList: []
    }
  },
  methods: {
    chat() {
      // console.log(this.inputValue);
      // console.log(this);
      // 二.获取自己输入内容,将内容渲染到页面
      this.messageList.push({
        message: this.inputValue,
        isSelf: true
      })
      this.inputValue = '' // 最后清除文本框
    }
  }
}
</script>

<style scoped lang="less">
  .chat-box{
    /*background-color: blanchedalmond;*/
    background-image: url("../../assets/images/home-part3.png");
    padding: 10%;
    height: 100%;
    .box-title{
      font-size: 30px;
      font-weight: 700;
    }

  }
  .box-container{
    border-radius: 10px;
    background-color: white;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 500px;
    .title{
      margin-top: 10px;
      padding-left: 10px;
      background-color: white;
      padding-bottom: 5px;
      span{
        color: #999999;
        font-size: 13px;
      }
    }
    .chat-content{
      height: 100%;
      background-color: #dcdcdc54;
      max-height: 383px;
      .des{
        text-align: center;
        color: #a1a1a1;
      }
      .content {
        /*必须加上！！！不然会溢出！*/
        max-height: 320px;
        font-size: 20px;
        overflow: auto;
        padding: 5px;
        li {
          margin-top: 10px;
          padding-left: 10px;
          display: flex;
          flex-direction: row-reverse;
          clear: both;
          overflow: hidden;
          img{
            border-radius: 10px;
          }
          .dialog{
            /*overflow: hidden;*/
            margin-right: 10px;
            /*float: right;*/
            display: block;
            word-break: break-all;
            word-wrap: break-word;
            background-color: #7cfc00;
            padding: 6px 15px;
            border-radius: 10px;
            border: 1px solid #ccc;
            box-shadow: 0 0 3px #ccc
          }
        }

      }
      .content li img.imgleft {
        float: left;
      }
      .content li img.imgright {
        /*float: right;*/
      }
      .content li span.spanleft {
        float: left;
        background: #fff;
      }
      .content li span.spanright {
        float: right;
        background: #7cfc00;
      }
    }
    .box-bottom{
      /*height: 10%;*/
    }
  }
</style>
